package com.luoboduner.moo.tool.ui.dialog.JsonDialog;

import com.luoboduner.moo.tool.util.MockDataGenerator;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
/**
 * @author Liutime
 */
@Data
public class KeyValue {

  /**
   * 对应类型文件以及 和 对应的转换方法
   */
  public static final Map<String, KeyValue> map = new HashMap<>() {{
    put("XML", new KeyValue("XML", MockDataGenerator::classCodeToJson));
    put("JSON", new KeyValue("JSON", MockDataGenerator::classCodeToJson));
    put("Java", new KeyValue("Java", MockDataGenerator::jsonToClassCode));
    put("SQL", new KeyValue("SQL", MockDataGenerator::classCodeToJson));
    put("HTML", new KeyValue("HTML", MockDataGenerator::classCodeToJson));
    put("JavaScript", new KeyValue("JavaScript", MockDataGenerator::classCodeToJson));
    put("CSS", new KeyValue("CSS", MockDataGenerator::classCodeToJson));
  }};

  /**
   * 文件类型
   */
  String key;

  /**
   * 转换方法
   */
  Function<String, String> value;

  public KeyValue(String key, Function<String, String> value) {
    this.key = key;
    this.value = value;
  }
}
